﻿using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;

namespace Canteen.Core.Common
{
    public interface IJwtAuth
    {
        public JwtAuthOptions Option { get; set; }

        /// <summary>
        /// 从Token中获取用户身份
        /// </summary>
        ClaimsPrincipal GetPrincipal(string Token);
        /// <summary>
        /// 生成JWT字符串
        /// </summary>
        /// <param name="Claims"></param>
        /// <returns></returns>
        string GenerateToken(List<Claim> Claims);
        /// <summary>
        /// 生成刷新Token
        /// </summary>
        /// <returns></returns>
        string GenerateRefreshToken();

        /// <summary>
        /// 创建刷新Token  --RedisDB6
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns>返回刷新Token字符串</returns>
        Task<string> CreateRefreshToken(int UserId);
        /// <summary>
        /// 验证刷新token是否存在或过期
        /// </summary>
        /// <param name="RefreshToken">刷新Token字符串</param>
        /// <returns></returns>
        Task<bool> ValidRefreshToken(string RefreshToken);
        /// <summary>
        /// 移除刷新token
        /// </summary>
        /// <param name="RefreshToken">刷新Token字符串</param>
        /// <returns></returns>
        Task RemoveRefreshToken(string RefreshToken);
    }
}
